/**
 * @param {number[]} prices
 * @return {number}
 */
var maxProfit = function(prices) {
    let length = prices.length;
    if(length<=0)return 0;

    let i = 1,
        res = 0;

    for(;i<length;i++){
        if(prices[i-1]<prices[i]){
            res += prices[i] - prices[i-1];
        }
    }
    return res;
};